#include "Stack(List).h"
#include<stdlib.h>

LinkStack_t createStack(LinkStack_t* table)
{
	LinkStack_t* table = (LinkStack_t*)malloc(sizeof(LinkStack_t));
	table->top = NULL;
	table->count = 0;
	return table;
}

void pushStack(LinkStack_t* table, Element_t e)
{
	NodeStack* new_node = (NodeStack*)malloc(sizeof(NodeStack));
	new_node->data = e;
	new_node->next =table->top;
	table->top = new_node;
	++table->count;
}

void popStack(LinkStack_t* table)
{
	NodeStack* tmp = table->top;
	table->top = table->top->next;
	free(tmp);
	--table->count;
}

void releaseStack(LinkStack_t* table)
{
	
	while (table->top->next != NULL)
	{
		NodeStack* tmp = table->top;
		table->top = table->top->next;
		free(tmp);
		--table->count;
	}
}



